package com.zn.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zn.Vo.CareerAndAdminVo;
import com.zn.bean.Career;
import com.zn.service.CareerService;
import com.zn.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 码农小周
 * @since 2023-05-12
 */

@Api(tags = "职业相关操作")
@RestController
@RequestMapping("/career")
public class CareerController {


    @Resource
    private CareerService careerService;


    /**
     * 查询所有职业
     * @return
     */
    @GetMapping("/careerList")
    @ApiOperation(value = "查询所有职业")
    public Result<Page<CareerAndAdminVo>> CareerList(Long page, Long pageSize, String careerName){
        return careerService.CareerList(page,pageSize,careerName);
    }


    /**
     * 新增职业
     * @param career
     * @return
     */
    @PostMapping ("/addCareer")
    @ApiOperation(value = "新增职业")
    public Result<String> addCareer(@RequestBody Career career){
        return careerService.addCareer(career);
    }


    /**
     * 修改职业
     * @param career
     * @return
     */
    @PostMapping ("/editCareer")
    @ApiOperation(value = "修改职业")
    public Result<String> editCareer(@RequestBody Career career){
        return careerService.editCareer(career);
    }


    @GetMapping ("/delCareer")
    @ApiOperation(value = "删除职业")
    public Result<String> delCareer(Long  id){
        return careerService.delCareer(id);
    }
}
